package validator

import "regexp"

type numberType struct{}

var numberReg = regexp.MustCompile("^(0|[1-9][0-9]*)$")

func (t *numberType) Validate(name string, val string, required bool) (bool, string) {
	if val == "" {
		if required {
			return false, name + "不能为空"
		}
		return true, ""
	}

	if !numberReg.MatchString(val) {
		return false, name + "应为含0的整数"
	}

	return true, ""
}
